package com.chenjinyan.back.dao;

import com.chenjinyan.back.entity.ConnectionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

@Repository
public interface ConnectionRepository extends JpaRepository<ConnectionEntity, Long> {
    @Modifying
    @Query(value = "INSERT INTO lost_and_find_connection(NAME,URL,DESCRIPTION) "
            + "VALUES(?1,?2,?3)", nativeQuery = true)
    @Transactional
    int insertConnection(String name, String url, String description);

    @Override
    @Modifying
    @Transactional
    ConnectionEntity saveAndFlush(ConnectionEntity goodsEntity);
}
